package com.lamthun.common.exception;

import com.lamthun.common.client.CommonCode;

public class CommonException extends RuntimeException {
    private String errorCode;
    private String errorMessage;

    public CommonException() {
        super(CommonCode.FAILED.getMessage());
        this.errorCode = CommonCode.FAILED.getCode();
        this.errorMessage = CommonCode.FAILED.getMessage();
    }

    public CommonException(String message) {
        super(message);
        this.errorCode = CommonCode.FAILED.getCode();
        this.errorMessage = message;
    }

    public CommonException(String code, String message) {
        super(message);
        this.errorCode = code;
        errorMessage = message;
    }

    public CommonException(Throwable cause) {
        super(cause);
        this.errorCode = CommonCode.FAILED.getCode();
        this.errorMessage = null != cause.getMessage() ? cause.getMessage() : CommonCode.FAILED.getMessage();
    }

    public CommonException(String message, Throwable cause) {
        super(message, cause);
        this.errorCode = CommonCode.FAILED.getCode();
        this.errorMessage = message;
    }

    public CommonException(String code, String message, Throwable cause) {
        super(message, cause);
        this.errorCode = code;
        this.errorMessage = message;
    }

    public String getErrorCode() {
        return errorCode;
    }

    public String getErrorMessage() {
        return errorMessage;
    }
}
